package com.libreaccess.reporting.utils;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.libreaccess.reporting.utils.ReportUtil;

import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.design.JasperDesign;

@SuppressWarnings("unchecked")
public class ReportingPortletDataPerUser implements Serializable{
	
	private static final long serialVersionUID = 1L;
	final Log logger = LogFactory.getLog(ReportingPortletDataPerUser.class);
	
	private String parameters = "";
	private long tabSelected = 0l;
	private ReportingEnums.ButtonIds btnPressedId;
	private Long currentReportId = null;
	private Long currentViewId = null;
//	private HashMap<String, String> paramValues = null;
	private HashMap<String, Object> model = null;
	private JasperDesign design;
	private JasperPrint print;
	private String reportName;
	public Map imagesMap;
	private String sessionId;
	private ReportingEnums.Window window = ReportingEnums.Window.reportManager;
	private String myReportName;
	private String myReportNameInDB;
	private Date lastCallSession; 
	private String isDefaultAction;
	private String completedReportName;
	private ReportUtil reportUtil = new ReportUtil();
	
	
	public ReportingPortletDataPerUser() {}

	public String getParameters() {
		return parameters;
	}
	public void setParameters(String parameters) {
		this.parameters = parameters;
	}
	public Long getTabSelected() {
		return tabSelected;
	}
	public void setTabSelected(Long tabSelected) {
		this.tabSelected = tabSelected;
	}

	public ReportingEnums.ButtonIds getBtnPressedId(){
		return btnPressedId;
	}
	public void setBtnPressedId(ReportingEnums.ButtonIds btnPressedId) {
		this.btnPressedId = btnPressedId;
	}

	public Long getCurrentReportId() {
		return currentReportId;
	}
	public void setCurrentReportId(Long currentReportId) {
		this.currentReportId = currentReportId;
	}

	public Long getCurrentViewId() {
		return currentViewId;
	}
	public void setCurrentViewId(Long currentViewId) {
		this.currentViewId = currentViewId;
	}

	public HashMap<String, Object> getModel() {
		return model;
	}
	public void setModel(HashMap<String, Object> model) {
		this.model = model;
	}
	
	public JasperDesign getDesign() {
		return design;
	}
	public void setDesign(JasperDesign design) {
		this.design = design;
	}

	public JasperPrint getPrint() {
		return print;
	}
	public void setPrint(JasperPrint print) {
		this.print = print;
	}

	public String getReportName() {
		return reportName;
	}
	public void setReportName(String reportName) {
		this.reportName = reportName;
	}
/*	
	public Map getImagesMap() {
		return imagesMap;
	}
	public void setImagesMap(Map imagesMap) {
		this.imagesMap = imagesMap;
	}
*/
	public String getSessionId() {
		return sessionId;
	}
	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}
	
	public ReportUtil getReportUtil() {
		return reportUtil;
	}
/*	public void setReportUtil(ReportUtilValues paramName, Object value) {
		switch(paramName) {
		case email:
			reportUtil.setEmail(value!=null? value.toString():null);
			break;
		case isCalendarchoosed:
			reportUtil.setIsCalendarchoosed((Boolean)value);
			break;
		case isSchedulerVisible:
			reportUtil.setSchedulerVisible((Boolean)value);
			break;
		case myReportId:
			reportUtil.setMyReportId(Long.parseLong(value!=null? value.toString():"0"));
			break;
		case parameters:
			reportUtil.setParameters((HashMap<String, String>)value);
			break;
		case reportFormat:
			reportUtil.setReportFormat((Utils.Format)value);
			break;
		case reportsFolder:
			reportUtil.setReportsFolder(value!=null? value.toString():null);
			break;
		case schedulerCountToRun:
			reportUtil.setSchedulerCountToRun(Long.parseLong(value!=null? value.toString():"0"));
			break;
		case schedulerDay:
			reportUtil.setSchedulerDay(Long.parseLong(value!=null? value.toString():"0"));
			break;
		case schedulerFrequency:
			reportUtil.setSchedulerFrequency((Utils.SchedulerFrequency)value);
			break;
		case schedulerRecurringDate:
			reportUtil.setSchedulerRecurringDate(value!=null? value.toString():null);
			break;
		case schedulerRecurringDatePrefix:
			reportUtil.setSchedulerRecurringDatePrefix(value!=null? value.toString():null);
			break;			
		case schedulerStartDate:
			reportUtil.setSchedulerStartDate((Date)value);
			break;			
		case timesToExecute:
			reportUtil.setTimesToExecute(Long.parseLong(value!=null? value.toString():null));
			break;
		case triggerExpr:
			reportUtil.setTriggerExpr((CronTriggerExpr)value);
			break;
		case triggerId:
			reportUtil.setTriggerId(value!=null? value.toString():null);
			break;		
		case userName:
			reportUtil.setUserName(value!=null? value.toString():null);
			break;			
		case viewId:
			reportUtil.setViewId(Long.parseLong(value!=null? value.toString():"0"));
			break;			
		}
	}
	*/
	public ReportingEnums.Window getWindow() {
		return window;
	}
	public void setWindow(ReportingEnums.Window window) {
		this.window = window;
	}

	public String getMyReportName() {
		return myReportName;
	}
	public void setMyReportName(String myReportName) {
		this.myReportName = myReportName;
	}

	public String getMyReportNameInDB() {
		return myReportNameInDB;
	}
	public void setMyReportNameInDB(String myReportNameInDB) {
		this.myReportNameInDB = myReportNameInDB;
	}
	
	public Date getLastCallSession() {
		return lastCallSession;
	}
	public void setLastCallSession(Date lastCallSession) {
		this.lastCallSession = lastCallSession;
	}
	
	public String getCompletedReportName() {
		return completedReportName;
	}
	public void setCompletedReportName(String completedReportName) {
		this.completedReportName = completedReportName;
	}
	
	public String getIsDefaultAction() {
		return isDefaultAction;
	}
	public void setIsDefaultAction(String isDefaultAction) {
		this.isDefaultAction = isDefaultAction;
	}
	
	public void clearData()
	{
		logger.info("inside clearData!!!!");
		tabSelected = 0l;
		currentReportId = null; 
		currentViewId = null; 
		btnPressedId = null;
		window = null;
		myReportName = null;
		myReportNameInDB = null;
		parameters = "";
		completedReportName = null;
		isDefaultAction = "false";
		reportUtil.setMyReportId(0l); // it needs, otherwise new myreport will be remove previous myreport.
		reportUtil.clearSchedulerData();
//		loggedUser = null;
//		reportsFolder = null;
	}
}
